/*
 * @lc app=leetcode.cn id=2319 lang=typescript
 *
 * [2319] 判断矩阵是否是一个 X 矩阵
 */

// @lc code=start
function checkXMatrix(grid: number[][]): boolean {
    for (let y = 0; y < grid.length; y++) {
        const row = grid[y];
        for (let x = 0; x < row.length; x++) {
            const el = row[x];
            if (x === y || x + y === grid[0].length - 1) {
                if (el === 0) return false;
            } else {
                if (el !== 0) return false;
            }
        }
    }
    return true;
}
// @lc code=end
